<?php $this->headStyle()->captureStart()?>
    #content td { padding:5px}
    #content table { border:1px #aaa solid; padding:5px; width:100%}
    #content th {font-weight:bold;}

<?php $this->headStyle()->captureEnd()?>
<table class="actions">
    <tr>
        <td>
            <a href="<?php echo $this->geturl('ban','company', null, 'admin1', array('id'=> $this->company->_id))?>">Ban</a>
        </td>
        <?php if (($this->company->status == Model_Company::STATUS_ACTIVE) || (!isset($this->company->status))) :?>
        <td>
            <a href="<?php echo $this->geturl('delete','company', null, 'admin1', array('id'=> $this->company->_id))?>">Delete</a>
        </td>
        <?php else:?>
        <td>
            <a href="<?php echo $this->geturl('activate','company', null, 'admin1', array('id'=> $this->company->_id))?>">Activate</a>
        </td>
        <?php endif;?>
        <td>
            <a href="<?php echo $this->company->url()?>" target="blank">Display in website</a>
        </td>
    </tr>
</table>

<table id="company">
    <tr>
        <th style="width:300px">Phone</th>
        <td colspan="2"><?php echo $this->company->phone?></td>
    </tr>
    <tr>
        <th>email</th>
        <td colspan="2"><?php echo $this->company->email?></td>
    </tr>
    <tr>
        <th>Mailling Address</th>
        <td colspan="2"><?php echo $this->company->mailing_address?></td>
    </tr>
    <tr>
        <th>Contact Firstname</th>
        <td colspan="2"><?php echo $this->company->contact_firstname?></td>
    </tr>
    <tr>
        <th>Contact Lastname</th>
        <td colspan="2"><?php echo $this->company->contact_lastname?></td>
    </tr>
    <tr>
        <th>Company Logo</th>
        <td><?php echo $this->company->image?></td>
        <td>
			<form method="post" enctype="multipart/form-data">
				<input type="file" name="pic"/> <input type="submit" name="update" value="Update"/>
			</form>
		</td>
    </tr>
</table>

<?php $data  = Model_User::all(array('cid' => $this->company->_id)); ?>
<?php $count = Model_User::all(array('cid' => $this->company->_id))->count(); ?>
<?php if ($count != 0):?>
<table border="1" id="listings">
    <tr>
        <td colspan="4">&nbsp;</td>
    </tr>
    <tr>
        <th colspan="4">Users (<?php echo $count?>)</th>
    </tr>
    <tr>
        <th>Email</th>
        <th>User</th>
        <th>Type Account</th>
        <th>Status</th>
    </tr>
    <?php foreach ($data as $user):?>
    <tr>
        
        <td>
            <a href="<?php echo $this->geturl('display', 'user', null, 'admin1', array('id'=> $user->_id))?>" target="_blank">
                <?php echo htmlentities($user->email, ENT_COMPAT, 'utf-8'); ?>
            </a>
        </td>
        <td><?php echo $user->username ?></td>
        
        <td>
            <?php
            if ($user->type_account == Model_User::COMPANY_ADMIN) {
                echo 'Company Admin';
            }
            elseif ($user->type_account == Model_User::AGENT) {
                echo 'Agent';
            }
            elseif ($user->type_account == Model_User::PERSONAL) {
                echo 'Personal';
            }
            ?>
        </td>
        <td><?php echo $user->status ?></td>
    </tr>
    <?php endforeach; ?>
</table>
<?php endif;?>